import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class mod {
    public static void main (String[] args) throws IOException{
        if (args.length<1) throw new RuntimeException ("not enough arguments");
        if (args.length>1) throw new RuntimeException ("too many arguments");
        BufferedReader reader = new BufferedReader (new FileReader (new File (args[0])));
        String line;
        while ((line = reader.readLine()) != null){          
           String[] nums = line.split(",");
           int N = Integer.parseInt(nums[0]);
           int M = Integer.parseInt(nums[1]); 
           int modulus =  N - (N/M) * M;
           System.out.println(modulus);
        }
    }
}
